<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var today = new Date()
        var date = new Date(2008,8,8)
        console.log(today)

        var year = today.getFullYear()
        var month = checkNum(today.getMonth() + 1)
        var day = checkNum(today.getDate())
        var hour = checkNum(today.getHours())
        var minute = checkNum(today.getMinutes())
        var second = checkNum(today.getSeconds())

        // var currTime = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second
        /**
         * 模板字符串
         */ 
        var currTime = `${year}-${month}-${day} ${hour}:${minute}:${second}`

        console.log(currTime)


        /**
         * 判断个数，补0
         */ 
        function checkNum(num){
            return num < 10 ? '0' + num : num
        }
    </script>
</head>
<body>
    
</body>
</html>